﻿using Microsoft.EntityFrameworkCore;
using RBACProject.Domian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RBACProject.Repositories
{
    /// <summary>
    /// 创建我的上下文类
    /// </summary>
    public class MyDbContext : DbContext
    {
        /// <summary>
        /// 构造函数获取上下文
        /// </summary>
        /// <param name="options"></param>
        public MyDbContext(DbContextOptions<MyDbContext> options) : base(options)
        {
        }


        /// <summary>
        /// 映射用户信息
        /// </summary>
        public DbSet<UserModel> UserModel { get; set; }

        /// <summary>
        /// 映射角色信息
        /// </summary>
        public DbSet<RoleModel> RoleModel { get; set; }

        /// <summary>
        /// 映射用户角色关系信息
        /// </summary>
        public DbSet<UserRoleModel> UserRoleModel { get; set; }



        /// <summary>
        /// 映射菜单信息
        /// </summary>
        public DbSet<MenuModel> MenuModel { get; set; }

        /// <summary>
        /// 映射角色菜单关系信息
        /// </summary>
        public DbSet<RoleMenuModel> RoleMenuModel { get; set; }




        //protected override void OnModleCreating(ModelBuilder modelBuilder)
        //{
        //    modelBuilder.Entity<UserModel>().HasKey(x => x.UserId);

        //    base.OnModelCreating(modelBuilder);

        //    modelBuilder.Entity<UserModel>(x =>
        //    {
        //        x.Property(x=>x.UserName).IsRequired().HasComment("用户名").HasMaxLength(50).IsUnicode().IsFixedLength(true);
        //        x.Property(x => x.Password).HasComment("密码").HasMaxLength(50);
        //        x.Property(x=>x.FullName).HasComment("全名").HasMaxLength(50).IsUnicode().IsFixedLength(true);
        //        x.Property(x=>x.Email).HasComment("邮箱").HasMaxLength(50).IsUnicode().IsFixedLength(true);
        //        x.Property(x => x.Avatar).HasComment("头像");
        //        x.Property(x => x.Remark).HasComment("备注");
        //        x.Property(x => x.LoginTime).HasComment("登录时间");
        //        x.Property(x => x.LoginIP).HasComment("登录IP");
        //    });
        //}


    }
}
    